home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TeX 1995 July
/
TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO
/
web
/
noweb
/
src
/
icon
/
elide.icn
< prev
next >
Wrap
Text File
|
1995-02-24
|
1KB
|
56 lines
#line 13 "elide.nw"
procedure main(args)
elide := []
every put(elide, globpat(!args))
while line := read() do
if match("@begin code ", line) then
{
#line 29 "elide.nw"
accum := [line]
while line := read() & not match("@defn ", line) do
put(accum, line)
line ? {
="@defn " | stop("This can't happen")
if globmatch(!elide) then {
while line := get(accum) | read() & not match("@end code ", line) do # drain
if line == "@nl" then write("@index nl") # grotesque, but may keep lines right
} else
every write(!accum | line)
}
#line 18 "elide.nw"
}
else
write(line)
return
end
#line 55 "elide.nw"
procedure globpat(s)
l := []
s ?
while not pos(0) do
put(l,
if not any('?*') then
tab(upto('?*')|0)
else case move(1) of {
"?" : &cset
"*" : &null
})
return l
end
#line 73 "elide.nw"
procedure doglobmatch(pat, i)
local p
suspend if p := pat[i] then
case type(p) of {
"string" : =p
"cset" : tab(any(p))
"null" : tab(&pos to *&subject+1)
} || doglobmatch(pat, i+1)
else (pos(0), "")
end
#line 87 "elide.nw"
procedure globmatch(pattern, s)
return if \s then s ? doglobmatch(pattern, 1)
else doglobmatch(pattern, 1)
end